package com.github.bitsapling.sapling.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.bitsapling.sapling.mapper.PromotionPolicyMapper;
import com.github.bitsapling.sapling.entity.PromotionPolicy;
import com.github.bitsapling.sapling.entity.User;
import com.github.bitsapling.sapling.service.PromotionPolicyService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class PromotionPolicyServiceImpl implements PromotionPolicyService {
    @Resource
    private PromotionPolicyMapper promotionPolicyMapper;

    @Override
    public PromotionPolicy getPromotionPolicyBySlug(String slug) {
        return promotionPolicyMapper.selectOne(
                new QueryWrapper<PromotionPolicy>().eq("slug", slug)
        );
    }

    @Override
    public PromotionPolicy getDefaultPromotionPolicy() {
        return promotionPolicyMapper.selectOne(
                new QueryWrapper<PromotionPolicy>().eq("slug", "normal")
        );
    }

    @Override
    public List<PromotionPolicy> queryAll() {
        return promotionPolicyMapper.selectList(
                new QueryWrapper<PromotionPolicy>()
        );
    }
}
